import { Component, EventEmitter, Input, Output, OnInit, ViewChild  } from '@angular/core';
import { PageModel } from "../../model/page-model";
import { NgModule  }      from '@angular/core';



@Component({
  selector: 'app-pagination',
  template: `
    <div class="text-center">
      <pagination [totalItems] ="pageModel.totalItems" [maxSize]="pageModel.maxSize" [rotate]="true"
                  [itemsPerPage]="pageModel.itemsPerPage" [(ngModel)]="pageModel.currentPage"
                  firstText="首页" lastText="尾页"
                  previousText="上一页" nextText="下一页"
                  [boundaryLinks]="true" [rotate]="false"
                  class="pagination-sm"
                  (numPages)="numPages = $event" (pageChanged)="setPage($event.page)" >
      </pagination>
    </div>
  `
})



export class AppPagination implements OnInit {


  @Input() public pageModel:PageModel;

  @Output() public pageChanged:EventEmitter<number> = new EventEmitter<number>();

  constructor() {}

  ngOnInit(){
  }
  public setPage(page:number){
    this.pageChanged.emit(page);
  }
}
